﻿@namespace BootstrapBlazor.Components
@typeparam TValue
@inherits SelectBase<TValue>

@if (IsShowLabel)
{
    <BootstrapLabel for="@Id" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
}
<div @attributes="@AdditionalAttributes" id="@Id" class="@DirectionClassName">
    <button type="button" class="@ButtonClassName" data-bs-toggle="@DropdownToggle" disabled="@Disabled">@ButtonText</button>
    @if (ShowSplit)
    {
        <button type="button" class="@ClassName" data-bs-toggle="dropdown" disabled="@Disabled" aria-haspopup="true" aria-expanded="false"></button>
    }
    @if (!IsDisabled)
    {
        <div class="@MenuAlignmentClass">
            @foreach (var item in GetItems())
            {
                if (ItemTemplate != null)
                {
                    @ItemTemplate.Invoke(item)
                }
                else if (item.IsDisabled)
                {
                    <div class="@ActiveItem(item)">@item.Text</div>
                }
                else
                {
                    <div class="@ActiveItem(item)" @onclick="e => OnItemClick(item)">@item.Text</div>
                }
            }
        </div>
    }
</div>
